package Studing;

import java.util.HashMap;

/**
 * @ClassName TestHuawei
 * @Description: TODO
 * @Author hl
 * @Date 2020/8/27
 * @Version V1.0
 **/
public class TestHuawei {
    public static void main(String[] args) {
        String input="a:3,b:5,c:2@a:1,b:2";
        String []temp=input.split("@");
        HashMap<String,Integer> map=new HashMap<>();
        for(int i=0;i<temp.length;i++){
            String []tem=temp[i].split(",");
            for(int j=0;j<tem.length;j++){
              String key=tem[j].split(":")[0];
              String value=tem[j].split(":")[1];

              if(map.containsKey(key)){
                  int a=map.get(key)-Integer.valueOf(value);
                  map.put(key,a);
              }else{
                  map.put(key,Integer.valueOf(value));
              }

            }
        }
        String s="";

        for(String key:map.keySet()){
            if(map.get(key)>0){
                s+=key+":"+map.get(key)+",";
            }
        }
        System.out.println(s.substring(0,s.length()-1));
    }

}
